package net.siufung.core.model.enums;

import com.google.common.collect.Lists;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import net.siufung.core.model.EnumsVo;

import java.util.List;

/**
 * @author 陈建峰
 * @since 2021/11/29 5:43 下午
 */
@ToString
public enum DraftEnum {

	/**
	 * 是
	 */
	NOT(false, "否"),
	/**
	 * 否
	 */
	IS(true, "是");

	@Getter
	@Setter
	private Boolean value;
	@Getter
	@Setter
	private String desc;

	DraftEnum(Boolean value, String desc) {
		this.value = value;
		this.desc = desc;
	}

	public static DraftEnum get(Boolean value) {
		DraftEnum[] draftFlagEnums = values();
		for (DraftEnum draftEnum : draftFlagEnums) {
			if (draftEnum.getValue().equals(value)) {
				return draftEnum;
			}
		}
		return null;
	}

	public static String getDesc(Boolean value) {
		DraftEnum[] draftFlagEnums = values();
		for (DraftEnum draftEnum : draftFlagEnums) {
			if (draftEnum.getValue().equals(value)) {
				return draftEnum.getDesc();
			}
		}
		return null;
	}

	public static List<EnumsVo> getList(){
		List<EnumsVo> draftFlagEnumList = Lists.newLinkedList();
		EnumsVo enumsVO = null;
		for (DraftEnum draftFlagEnum: values()) {
			enumsVO = new EnumsVo();
			enumsVO.setValue(draftFlagEnum.getValue());
			enumsVO.setDesc(draftFlagEnum.getDesc());
			draftFlagEnumList.add(enumsVO);
		}
		return draftFlagEnumList;
	}
	
}
